package qmm.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import qmm.dao.AddressDao;
import qmm.dao.impl.AddressDaoImpl;
import qmm.entity.Address;
import qmm.entity.User;

@WebServlet("/AddressServlet")
public class AddressServlet extends BaseServlet{
	
	AddressDao dao = new AddressDaoImpl();
	
	public void getDefaultAddress(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		
		Address address = dao.getDefaultAddress(user.getId());
		session.setAttribute("defaultAddress", address);
		response.getWriter().print("success");
	}
}
